﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Configuration;
using System.Data.SqlClient;
/// <summary>
/// Summary description for _Document_type
/// </summary>
public class _Document_type
{
	public _Document_type()
	{
		//
		// TODO: Add constructor logic here
		//
	}

    public int _id { get; set; }
    public string _document_type { get; set; }

    static SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["ApplicationServices"].ConnectionString);

    public static List<_Document_type> SelectDocumentTypes()
    {
        _Document_type item = new _Document_type();
        List<_Document_type> list = new List<_Document_type>();
        SqlCommand commandz = new SqlCommand("SELECT * FROM DOCUMENT_TYPE", conn);
        conn.Open();
        SqlDataReader dr = commandz.ExecuteReader();
        while (dr.Read())
        {
            item._id = (int) dr[0];
            item._document_type = dr[1].ToString();
            list.Add(item);
        }
        dr.Close();
        conn.Close();
        return list;
    }

    public static _Document_type SelectDocType(string id)
    {
        _Document_type DocType = new _Document_type();
        SqlCommand commandz = new SqlCommand("SELECT * FROM document_type WHERE id = @id", conn);
        commandz.Parameters.Add(new SqlParameter("@id", System.Data.SqlDbType.Int)).Value = id;
        conn.Open();
        SqlDataReader dr = commandz.ExecuteReader();
        while (dr.Read())
        {
            DocType._id = (int) dr[0];
            DocType._document_type = dr[1].ToString();
        }
        dr.Close();
        conn.Close();
        return DocType;
    }
}